function [ output ] = writeOut( midiFile )
% OMG!

midi = readmidi(midiFile);
info = midiInfo(midi,0);
notes = [info(:,3)];
stringNotes = [convertToString(notes(:))];
durations = [info(:,6)-info(:,5)];

len = length(notes);
filename = midi.filename;
fn = strrep(filename, '.mid', '');

output='';
olen=len;
for i=1:len
output=strcat(output,sprintf('{%s,%d},',stringNotes(i,:),round(100*durations(i))));
if(i<len) 
    gap = round(100*(info(i+1,5)-info(i,6)));
end
if(gap>20)
    output=strcat(output,sprintf('{0,%d},',gap));
    olen = olen + 1;
end

end
output = strcat(output,'}};');
output = strcat('static song_t ',' ',fn,' = { ',sprintf('%d ,{ ',olen),output);
